package com.nf.practice.sortlist;

public class Person3 implements Comparable{
    private String id;
    private String name;
    private String address;
 
    public Person3(String id, String name, String address) {
        this.id = id;
        this.name = name;
        this.address = address;
    }
 
    public String getId() {
        return id;
    }
 
    public void setId(String id) {
        this.id = id;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getAddress() {
        return address;
    }
 
    public void setAddress(String address) {
        this.address = address;
    }
 
    @Override
    public String toString() {
        return "Person{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", address='" + address + '\'' +
                '}';
    }
 
    @Override
    public int compareTo(Object o) {
        if (o instanceof Person3){
            Person3 o1 = (Person3)o;
            return new Double(this.getId()).compareTo(new Double(o1.getId()));
        }
        throw new ClassCastException("不能转换为Person类型的对象...");
    }
}